#ifndef USER_H
#define USER_H

#include <QString>
#include <QDateTime>
#include "gloablevariant.h"
// #include "QtMyBatisPlus.h"
// #include "autoincrementbase.h"
// #include "updatedtimebase.h"
// #include "createdtimebase.h"
#include "defaultbase.h"
#include <QVariantMap>
#include <optional>
class User : public DefaultBase
{
    Q_GADGET
    Q_CLASSINFO("TableName", "users")
    Q_CLASSINFO("Columns", "id,name,age,email,createTime,updateTime")
    Q_CLASSINFO("DefaultColumns","id,createTime,updateTime") //自增
    Q_CLASSINFO("PrimaryKey","id") //自增
    Q_CLASSINFO("AutoIncrement","id") //自增


    //1. 这个也没有问题
    //1，属性没有问题，字段和表的列对应起来
    Q_PROPERTY(int id MEMBER _id)
    Q_PROPERTY(QString name MEMBER _name)
    Q_PROPERTY(QString email MEMBER _email)
    Q_PROPERTY(QVariant age MEMBER _age)
    Q_PROPERTY(QDateTime createTime MEMBER _createdTime)
    Q_PROPERTY(QDateTime updateTime MEMBER _updatedTime)

public:

    User() {
        //autoIncrementChanges["Id_AutoIncrement"] = 0;
        _defaultMap["id"] = 0;
        _defaultMap["createTime"] = 0 ;
        _defaultMap["updateTime"] = 0 ;
    };

    User(const QString& name,const QString& email):_name(name),_email(email)
    {
        _defaultMap["id"] = 0;
        _defaultMap["createTime"] = 0 ;
        _defaultMap["updateTime"] = 0 ;
    }

    User(const QString& name, const QString& email, const int& age)
        : _name(name), _email(email), _age(age) {
        _defaultMap["id"] = 0;
        _defaultMap["createTime"] = 0 ;
        _defaultMap["updateTime"] = 0 ;

    }

    User(const int& id,const QString& name, const QString& email, const int& age)
        :_id(id), _name(name), _email(email), _age(age) {
        _defaultMap["id"] = 1; //有赋值
        _defaultMap["createTime"] = 0 ;
        _defaultMap["updateTime"] = 0 ;

    }

    //QMP_TABLE(users)
    void setId(const int& id){
        this->_id = id ; //
        _defaultMap["id"] = 1; //有赋值
    }
    int getId(){
        return this->_id;
    };

    void setName(const QString& name){
        this->_name  = name;
    }
    QString getName(){
        return this->_name;
    }

    void setEmail(const QString& email)
    {
        this->_email = email;
    }

    QString getEmail()
    {
        return this->_email ;
    }

    void setAge(const int& age){
        this->_age = age ;
    }

    QVariant getAge(){
        return this->_age;
    }

    void setCreatedTime(const QDateTime& createTime)
    {
        _defaultMap["createTime"] = 1 ;
        this->_createdTime = createTime;
    }

    QDateTime getCreatedTime()
    {
        return this->_createdTime ;
    }

    void setUpdatedTime(const QDateTime& updateTime)
    {
        _defaultMap["updateTime"] = 1 ;
        this->_updatedTime = updateTime;
    }

    QDateTime getUpdatedTime()
    {
        return this->_updatedTime ;
    }
private:
    int _id ; //如果有默认的，那么就
    QString _name ;
    QString _email;
    QVariant _age ;
    QDateTime _createdTime;
    QDateTime _updatedTime;
};
#endif // USER_H
